// NearbySetUp.cpp : implementation file
//

#include "stdafx.h"
#include "..\PubQQ.h"
#include "..\define\DefineUser.h"
//#include "..\define\DefineUser.h"
#include "NearbySetUp.h"

#include "..\include/IniFile.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNearbySetUp dialog

extern CIniFile file;
CNearbySetUp::CNearbySetUp(CWnd* pParent /*=NULL*/)
	: CNearbyBase(CNearbySetUp::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNearbySetUp)
	m_board = 1;
	m_accept = 1;
	m_ping = 1;
	m_reply = 1;
	//}}AFX_DATA_INIT
    nDlgType = NEARBY_SETUP;
}


void CNearbySetUp::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNearbySetUp)
	DDX_Radio(pDX, IDC_RADIO1, m_board);
	DDX_Radio(pDX, IDC_RADIO5, m_accept);
	DDX_Radio(pDX, IDC_RADIO9, m_ping);
	DDX_Radio(pDX, IDC_RADIO13, m_reply);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CNearbySetUp, CDialog)
	//{{AFX_MSG_MAP(CNearbySetUp)
	ON_WM_DESTROY()
	ON_WM_CTLCOLOR()
	ON_WM_ERASEBKGND()
    ON_WM_NCMOUSEMOVE()
	ON_MESSAGE(WM_GETEDITSTATE, EMReadyEditState)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNearbySetUp message handlers

BOOL CNearbySetUp::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CenterWindow(GetDesktopWindow());	
	// TODO: Add extra initialization here
    m_Ok.SubclassDlgItem(IDOK,this);
	m_Ok.SetFlat(false);
	m_Ok.DrawBorder(1,0);
	m_Ok.SetPushLike(1,0);
	m_Ok.DrawTransparent(true);
    m_Cancel.SubclassDlgItem(IDCANCEL,this);
	m_Cancel.SetFlat(false);
	m_Cancel.DrawBorder(1,0);
	m_Cancel.SetPushLike(1,0);
	m_Cancel.DrawTransparent(true);	
    SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), false);
    PostMessage(WM_GETEDITSTATE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CNearbySetUp::EMReadyEditState(WPARAM wParam, LPARAM lParam)
{
	//InitControl( );
    InitData( );
	setData();
	UpdateData(false);
}

void CNearbySetUp::InitControl( )
{

}

void CNearbySetUp::setData( )
{
	m_board = nUserId;
	m_accept = oldId;
	m_ping = nType;
	m_reply = oldType;
}

void CNearbySetUp::OnOK() 
{
		UpdateData(TRUE);
	nUserId = m_board;
	oldId = m_accept;
	nType = m_ping;
	oldType = m_reply;

	Reply();

	CNearbyBase::OnOK();
}

void CNearbySetUp::Reply() 
{
	SaveToFile();
}
